﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt.oracle
{
	// Token: 0x0200013D RID: 317
	public class TPlsqlExecImmeStmt : TBlockSqlStatement
	{
		// Token: 0x170001EC RID: 492
		// (get) Token: 0x06000A75 RID: 2677 RVA: 0x00304FAC File Offset: 0x003031AC
		// (set) Token: 0x06000A76 RID: 2678 RVA: 0x0030502E File Offset: 0x0030322E
		public virtual TStatementList DynamicStatements
		{
			get
			{
				if (this.dynamicStatements != null)
				{
					return this.dynamicStatements;
				}
				if (this.DynamicSQL == null)
				{
					return null;
				}
				TGSharpSqlParser tGSharpSqlParser = new TGSharpSqlParser(EDbVendor.dbvoracle);
				tGSharpSqlParser.sqltext = this.DynamicSQL;
				if (tGSharpSqlParser.parse() != 0)
				{
					return null;
				}
				this.dynamicStatements = new TStatementList();
				for (int i = 0; i < tGSharpSqlParser.sqlstatements.size(); i++)
				{
					this.dynamicStatements.add(tGSharpSqlParser.sqlstatements.get(i));
				}
				return this.dynamicStatements;
			}
			set
			{
				this.dynamicStatements = value;
			}
		}

		// Token: 0x170001ED RID: 493
		// (get) Token: 0x06000A77 RID: 2679 RVA: 0x00305038 File Offset: 0x00303238
		// (set) Token: 0x06000A78 RID: 2680 RVA: 0x003051A3 File Offset: 0x003033A3
		public virtual string DynamicSQL
		{
			get
			{
				if (this.dynamicSQL != null)
				{
					return this.dynamicSQL;
				}
				if (this.dynamicStringExpr.ExpressionType == EExpressionType.simple_constant_t)
				{
					this.dynamicSQL = TBaseType.getStringInsideLiteral(this.dynamicStringExpr.ToString());
				}
				else if (this.dynamicStringExpr.ExpressionType == EExpressionType.simple_object_name_t)
				{
					string strB = this.DynamicStringExpr.ToString();
					TCustomSqlStatement topStatement = this.TopStatement;
					if (topStatement is TBlockSqlStatement)
					{
						int i = 0;
						while (i < ((TBlockSqlStatement)topStatement).BodyStatements.size())
						{
							TCustomSqlStatement tcustomSqlStatement = ((TBlockSqlStatement)topStatement).BodyStatements.get(i);
							if (tcustomSqlStatement is TAssignStmt && string.Compare(((TAssignStmt)tcustomSqlStatement).Left.ToString(), strB) == 0)
							{
								if (((TAssignStmt)tcustomSqlStatement).Expression.ExpressionType == EExpressionType.simple_constant_t)
								{
									this.dynamicSQL = ((TAssignStmt)tcustomSqlStatement).Expression.ToString().Substring(1, ((TAssignStmt)tcustomSqlStatement).Expression.ToString().Length - 2 - 1);
									break;
								}
								this.dynamicSQL = null;
								break;
							}
							else
							{
								i++;
							}
						}
					}
				}
				else
				{
					this.dynamicSQL = this.dynamicStringExpr.ToString();
					if (this.dynamicSQL[0] == '\'')
					{
						this.dynamicSQL = this.dynamicSQL.Substring(1, this.dynamicSQL.ToString().Length - 2 - 1);
					}
				}
				return this.dynamicSQL;
			}
			set
			{
				this.dynamicSQL = value;
			}
		}

		// Token: 0x170001EE RID: 494
		// (get) Token: 0x06000A79 RID: 2681 RVA: 0x003051AC File Offset: 0x003033AC
		// (set) Token: 0x06000A7A RID: 2682 RVA: 0x003051B4 File Offset: 0x003033B4
		public virtual TBindArgumentList BindArguments
		{
			get
			{
				return this.bindArguments;
			}
			set
			{
				this.bindArguments = value;
			}
		}

		// Token: 0x170001EF RID: 495
		// (get) Token: 0x06000A7B RID: 2683 RVA: 0x003051BD File Offset: 0x003033BD
		// (set) Token: 0x06000A7C RID: 2684 RVA: 0x003051C5 File Offset: 0x003033C5
		public virtual TExpression DynamicStringExpr
		{
			get
			{
				return this.dynamicStringExpr;
			}
			set
			{
				this.dynamicStringExpr = value;
			}
		}

		// Token: 0x170001F0 RID: 496
		// (get) Token: 0x06000A7D RID: 2685 RVA: 0x003051CE File Offset: 0x003033CE
		// (set) Token: 0x06000A7E RID: 2686 RVA: 0x003051D6 File Offset: 0x003033D6
		public virtual TExpressionList IntoVariables
		{
			get
			{
				return this.intoVariables;
			}
			set
			{
				this.intoVariables = value;
			}
		}

		// Token: 0x170001F1 RID: 497
		// (get) Token: 0x06000A7F RID: 2687 RVA: 0x003051DF File Offset: 0x003033DF
		// (set) Token: 0x06000A80 RID: 2688 RVA: 0x003051E7 File Offset: 0x003033E7
		public virtual TObjectNameList ReturnNames
		{
			get
			{
				return this.returnNames;
			}
			set
			{
				this.returnNames = value;
			}
		}

		// Token: 0x06000A81 RID: 2689 RVA: 0x003051F0 File Offset: 0x003033F0
		public TPlsqlExecImmeStmt(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstplsql_execimmestmt;
		}

		// Token: 0x06000A82 RID: 2690 RVA: 0x00305204 File Offset: 0x00303404
		internal override void buildsql()
		{
		}

		// Token: 0x06000A83 RID: 2691 RVA: 0x00305206 File Offset: 0x00303406
		internal override void clear()
		{
		}

		// Token: 0x06000A84 RID: 2692 RVA: 0x00305208 File Offset: 0x00303408
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000A85 RID: 2693 RVA: 0x0030520F File Offset: 0x0030340F
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x06000A86 RID: 2694 RVA: 0x00305214 File Offset: 0x00303414
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			base.doParseStatement(psql);
			TExecImmeNode texecImmeNode = (TExecImmeNode)this.rootNode;
			this.bindArguments = texecImmeNode.BindArguments;
			this.intoVariables = texecImmeNode.IntoVariables;
			this.dynamicStringExpr = texecImmeNode.DynamicStringExpr;
			this.returnNames = texecImmeNode.ReturnNames;
			return 0;
		}

		// Token: 0x06000A87 RID: 2695 RVA: 0x00305270 File Offset: 0x00303470
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000A88 RID: 2696 RVA: 0x00305280 File Offset: 0x00303480
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x04001286 RID: 4742
		private TExpression dynamicStringExpr;

		// Token: 0x04001287 RID: 4743
		private TBindArgumentList bindArguments;

		// Token: 0x04001288 RID: 4744
		private TExpressionList intoVariables;

		// Token: 0x04001289 RID: 4745
		private TObjectNameList returnNames;

		// Token: 0x0400128A RID: 4746
		private string dynamicSQL;

		// Token: 0x0400128B RID: 4747
		private TStatementList dynamicStatements;
	}
}
